package com.lcj;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.spring.SpringGeccoEngine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@SpringBootApplication
@Configuration
public class CrawlerApplication {
    @Bean
    public SpringGeccoEngine initGecco() {
        return new SpringGeccoEngine() {
            @Override
            public void init() {
                HttpGetRequest start = new HttpGetRequest("http://www.cshr.com.cn/csrcwhr/company/chtml/00042435.html");
                start.setCharset("UTF-8");
                GeccoEngine.create()
                        .pipelineFactory(springPipelineFactory)
                        .classpath("com.lcj")
                        .start(start)
                        .interval(3000)
                        .debug(false)
                        .start();
            }
        };
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(CrawlerApplication.class, args);
    }
}